grideye2 2.2.1
Loading...
Searching...
No Matches
grideye2.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef GRIDEYE2_H
29#define GRIDEYE2_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
58
63
68
73#define GRIDEYE2_REG_PCLT 0x00
74#define GRIDEYE2_REG_RST 0x01
75#define GRIDEYE2_REG_FPSC 0x02
76#define GRIDEYE2_REG_INTC 0x03
77#define GRIDEYE2_REG_STAT 0x04
78#define GRIDEYE2_REG_SCLR 0x05
79#define GRIDEYE2_REG_AVE 0x07
80#define GRIDEYE2_REG_INTHL 0x08
81#define GRIDEYE2_REG_INTHH 0x09
82#define GRIDEYE2_REG_INTLL 0x0A
83#define GRIDEYE2_REG_INTLH 0x0B
84#define GRIDEYE2_REG_IHYSL 0x0C
85#define GRIDEYE2_REG_IHYSH 0x0D
86#define GRIDEYE2_REG_TTHL 0x0E
87#define GRIDEYE2_REG_TTHH 0x0F
88#define GRIDEYE2_REG_INT0 0x10
89#define GRIDEYE2_REG_INT1 0x11
90#define GRIDEYE2_REG_INT2 0x12
91#define GRIDEYE2_REG_INT3 0x13
92#define GRIDEYE2_REG_INT4 0x14
93#define GRIDEYE2_REG_INT5 0x15
94#define GRIDEYE2_REG_INT6 0x16
95#define GRIDEYE2_REG_INT7 0x17
96#define GRIDEYE2_REG_AVE_SET 0x1F
97#define GRIDEYE2_REG_TO1L 0x80
98#define GRIDEYE2_REG_TO1H 0x81
99 // grideye2_reg
101
106
111
116#define GRIDEYE2_PCLT_NORMAL_MODE 0x00
117#define GRIDEYE2_PCLT_SLEEP_MODE 0x10
118
123#define GRIDEYE2_RST_FLAG 0x30
124#define GRIDEYE2_RST_INITIAL 0x3F
125
130#define GRIDEYE2_FPSC_10FPS 0x00
131#define GRIDEYE2_FPSC_1FPS 0x01
132
137#define GRIDEYE2_INTC_INTMOD_DIFF 0x00
138#define GRIDEYE2_INTC_INTMOD_ABS 0x02
139#define GRIDEYE2_INTC_INTMOD_MASK 0x02
140#define GRIDEYE2_INTC_INTEN_INACTIVE 0x00
141#define GRIDEYE2_INTC_INTEN_ACTIVE 0x01
142#define GRIDEYE2_INTC_INTEN_MASK 0x01
143
148#define GRIDEYE2_STAT_OVF_IRS 0x04
149#define GRIDEYE2_STAT_INTF 0x02
150
157#define GRIDEYE2_AVE_MAMOD_OFF 0x00
158#define GRIDEYE2_AVE_MAMOD_ON 0x20
159#define GRIDEYE2_AVE_SET_0 0x50
160#define GRIDEYE2_AVE_SET_1 0x45
161#define GRIDEYE2_AVE_SET_2 0x57
162#define GRIDEYE2_AVE_SET_3 0x00
163
168#define GRIDEYE2_DATA_SIGN_BIT 0x0800
169#define GRIDEYE2_DATA_FILL_SIGN 0xF000
170#define GRIDEYE2_DATA_LSB 0.25f
171#define GRIDEYE2_NUM_PIXELS 64
172
178#define GRIDEYE2_DEVICE_ADDRESS_0 0x68
179#define GRIDEYE2_DEVICE_ADDRESS_1 0x69
180 // grideye2_set
182
187
192
197#define GRIDEYE2_MAP_MIKROBUS( cfg, mikrobus ) \
198 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
199 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
200 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
201 // grideye2_map // grideye2
204
209typedef struct
210{
211 // Input pins
212 digital_in_t int_pin;
213
214 // Modules
215 i2c_master_t i2c;
216
217 // I2C slave address
219
221
222} grideye2_t;
223
228typedef struct
229{
230 pin_name_t scl;
231 pin_name_t sda;
232
233 pin_name_t int_pin;
234
235 uint32_t i2c_speed;
236 uint8_t i2c_address;
237
239
244typedef enum
245{
248
250
256
267
282
296
311err_t grideye2_write_reg_bytes ( grideye2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
312
325err_t grideye2_write_reg_byte ( grideye2_t *ctx, uint8_t reg, uint8_t data_in );
326
340err_t grideye2_write_reg_word ( grideye2_t *ctx, uint8_t reg, uint16_t data_in );
341
356err_t grideye2_read_reg_bytes ( grideye2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
357
370err_t grideye2_read_reg_byte ( grideye2_t *ctx, uint8_t reg, uint8_t *data_out );
371
385err_t grideye2_read_reg_word ( grideye2_t *ctx, uint8_t reg, uint16_t *data_out );
386
396
409
421
422#ifdef __cplusplus
423}
424#endif
425#endif // GRIDEYE2_H
426 // grideye2
428
429// ------------------------------------------------------------------------ END
grideye2_return_value_t
Grid-EYE 2 Click return value data.
Definition grideye2.h:245
@ GRIDEYE2_ERROR
Definition grideye2.h:247
@ GRIDEYE2_OK
Definition grideye2.h:246
#define GRIDEYE2_NUM_PIXELS
Definition grideye2.h:171
err_t grideye2_write_reg_byte(grideye2_t *ctx, uint8_t reg, uint8_t data_in)
Grid-EYE 2 write reg byte function.
err_t grideye2_read_reg_word(grideye2_t *ctx, uint8_t reg, uint16_t *data_out)
Grid-EYE 2 read reg word function.
err_t grideye2_read_grid(grideye2_t *ctx)
Grid-EYE 2 read grid function.
err_t grideye2_read_reg_bytes(grideye2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Grid-EYE 2 read reg bytes function.
err_t grideye2_read_reg_byte(grideye2_t *ctx, uint8_t reg, uint8_t *data_out)
Grid-EYE 2 read reg byte function.
uint8_t grideye2_get_int_pin(grideye2_t *ctx)
Grid-EYE 2 get INT pin function.
err_t grideye2_clear_status(grideye2_t *ctx)
Grid-EYE 2 clear status function.
void grideye2_cfg_setup(grideye2_cfg_t *cfg)
Grid-EYE 2 configuration object setup function.
err_t grideye2_write_reg_word(grideye2_t *ctx, uint8_t reg, uint16_t data_in)
Grid-EYE 2 write reg word function.
err_t grideye2_init(grideye2_t *ctx, grideye2_cfg_t *cfg)
Grid-EYE 2 initialization function.
err_t grideye2_default_cfg(grideye2_t *ctx)
Grid-EYE 2 default configuration function.
err_t grideye2_write_reg_bytes(grideye2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Grid-EYE 2 write reg bytes function.
Grid-EYE 2 Click configuration object.
Definition grideye2.h:229
uint32_t i2c_speed
Definition grideye2.h:235
pin_name_t scl
Definition grideye2.h:230
pin_name_t int_pin
Definition grideye2.h:233
pin_name_t sda
Definition grideye2.h:231
uint8_t i2c_address
Definition grideye2.h:236
Grid-EYE 2 Click context object.
Definition grideye2.h:210
digital_in_t int_pin
Definition grideye2.h:212
i2c_master_t i2c
Definition grideye2.h:215
float grid_temp[GRIDEYE2_NUM_PIXELS]
Definition grideye2.h:220
uint8_t slave_address
Definition grideye2.h:218